
#include <stdio.h>
#include "pilha.h"

// test 3

int main()
{
 Pilha stack;
 char string[20];
 char c;
 float f;
 do 
 {
   printf(">");
   gets(string);
   if( sscanf(string,"%f",&f) == 1 )
   {
     stack.push( f );
   }
   else
   {
     switch (string[0])
     {
     case '+':
       {
         float v1 = stack.pop();
         float v2 = stack.pop();
         stack.push(v1+v2);
         printf(">%.2f\n",v1+v2);
         break;
       }
     case '-':
       {
         float v1 = stack.pop();
         float v2 = stack.pop();
         stack.push(v2-v1);
         printf(">%.2f\n",v2-v1);
         break;
       }
     case '*':
       {
         float v1 = stack.pop();
         float v2 = stack.pop();
         stack.push(v2*v1);
         printf(">%.2f\n",v2*v1);
         break;
       }
     default:
       printf("Input error.\n");
     }
   }
 } while ( string[0] != 'p' );

stack.imprime();
 


}